using System;
using System.Text;
using InfoJetSoft.Service.XPath.Tokens;

//CID 0164 //2008.12.13 //Begin
namespace InfoJetSoft.Service.XPath.Exprs
{
	/// <summary>
	/// Summary description for Predicate.
	/// </summary>
    public class Predicate : IExpr
	{

		public Predicate()
		{
			//
			// TODO: Add constructor logic here
			//
        }

        public object Evaluate(ExprContext context)
        {
            return null;
        }

        //CID 0866 //2011.04.01 //Begin
        public void Visit(IExprVisitor visitor)
        {
        }
        //CID 0866 //2011.04.01 //End

        public void Print(StringBuilder buffer)
        {
        }

		public static IExpr Parse( ExprParser parser )
		{
			Token nextToken = parser.LookupNextToken(1);
			if( nextToken != null && nextToken.Type.Equals( TokenType.Symbol ) && nextToken.Value.Equals( "[" ) )
			{
				parser.MoveNextIndex(1);
				
				IExpr subExpr = Expr.Parse( parser );
                if (subExpr != null)
				{
					Token nextToken2 = parser.LookupNextToken(1);
					if( nextToken2 != null && nextToken2.Type.Equals( TokenType.Symbol ) && nextToken2.Value.Equals( "]" ) )
					{
						parser.MoveNextIndex(1);

                        return subExpr;
					}
				}
				throw new Exception( "Cannot parse " + parser.XPath );
			}
			return null;
		}
	}
}
//CID 0164 //2008.12.13 //End
